<template>
    <div>
        <el-container class="form-container">
            <el-card class="box-card" shadow="never">
                <div slot="header" class="clearfix">
                    <span>接口列表</span>
                    <el-button type="primary" size="mini" style="float:right;padding: 6px 9px;" @click="handlerSubmitForm">保存</el-button>
                </div>
                <div>
                    <el-form  :rules="rules"  ref="form"  :model="form" size="small" label-width="120px">
                        <el-row>
                            <el-col :span="24">
                                <el-form-item  label="接口名称">
                                {{form.fdName}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item  label="接口路径">
                                    {{form.fdServicePath}}
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item  label="接口key">
                                    {{form.fdServiceKey}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item  label="策略" required>
                                    <el-select v-model="form.fdPolicyId" >
                                        <el-option v-for="item in plicyList" :key="item.value" :label="item.name" :value="item.value"/>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item  label="是否开启">
                                    {{form.fdEnable=='true'?'是':'否'}}
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item  label="创建时间">
                                    {{form.fdCreateTime}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item  label="备注">
                                    {{form.fdRemark}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </el-card>
        </el-container>
    </div>
</template>
<script>
import {edit,parentEdit} from '@/components/mixins/form'
export default {
    name: "sysRestMainEdit",
    components: {
    },
    data() {
        return {
            updateUrl:'/api/sys/rest/sys_rest_main',
            fetchUrl:'/api/sys/rest/sys_rest_main',
            fetchParentUrl:'/api/sys/rest/sys_rest_main',
            form: {
                fdId:'',
                fdCreateTime:'',
                fdName:'',
                fdServicePath:'',
                fdServiceKey:'',
                fdPolicyId:'',
                fdPolicyName:'',
                fdEnable:'',
                fdRemark:''
            },
            plicyList:[],   //策略列表
            rules:{
                fdCreateTime :[{required: true, message: '请输入创建时间', trigger: 'blur'}],
                fdName :[{required: true, message: '请输入接口名称', trigger: 'blur'}],
                fdServicePath :[{required: true, message: '请输入接口路径', trigger: 'blur'}],
                fdServiceKey :[{required: true, message: '请输入接口key', trigger: 'blur'}],
                fdPolicyId :[{required: true, message: '请选择策略', trigger: 'blur'}],
	        }
        }
    },
    mounted(){
        this.$nextTick(()=>{
            this.handlerGetAllPolicy();
        })
    },
    mixins:[edit,parentEdit],
    methods:{
        handlerGetAllPolicy(){
            this.$fetch('/api/sys/rest/sys_rest_policy/all',{}).then((res) => {
                if(res.status ===1){
                    console.log(res.data);
                    this.plicyList = this.plicyList.concat(res.data);
                }
            })
        }
    }
}
</script>
<style scoped>
@import "~@/assets/css/form.css";
</style>